package com.woniu.adapter;


import com.woniu.exception.ReportedForWorkException;
import com.woniu.outlet.client.WorkingProcedures;
import com.woniu.outlet.dao.ProcessHandoverMapper;
import com.woniu.outlet.po.ProcessHandover;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class WorkReportAdapter {

    @Autowired
    private ProcessHandoverMapper processHandoverMapper;
    @Autowired
    private WorkingProcedures workingProcedures;


    public void workReport (ProcessHandover processHandover) {
        ProcessHandover processHandover1 = processHandoverMapper.selectByPrimaryKey(processHandover.getId());
        if(processHandover1.getSpare1().equals("已报工")){
            throw new ReportedForWorkException("该工序已报工");
        }
        processHandoverMapper.updateByPrimaryKeySelective(processHandover);
        workingProcedures.addSystemLog("报工");
    }
}
